﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="UserProfile.aspx.cs" Inherits="UserProfile" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
    <script src="Scripts/dist/jquery.min.js" type="text/javascript"></script>
       <link href="Scripts/dist/jquery.jqplot.min.css" rel="stylesheet" type="text/css" />
        <script src="Scripts/dist/jquery.jqplot.min.js" type="text/javascript"></script>
            <script src="Scripts/dist/plugins/jqplot.cursor.min.js" type="text/javascript"></script>
    <script src="Scripts/dist/plugins/jqplot.pieRenderer.min.js" type="text/javascript"></script>

    <script language=javascript>
        $(document).ready(function () {
            var divToBeWorkedOn = 'chart1';
            var userName = $('#<%= Label1.ClientID %>').text();
            var webMethod = 'WebService.asmx/DisplayCurrentMarketValue';
            var parameters = "{'UserName':'" + userName + "'}";
            var data = [];

            $.ajax({
                type: "POST",
                url: webMethod,
                data: parameters,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {

                    var stocks = response.d;
                    if (stocks != null) {
                        for (var i = 0; i < stocks.length; ++i) {
                            var stock = stocks[i];

                            var row = [stock.Name, stock.Open];
                            data.push(row)
                        }

                        if (data.length > 0) {
                            //var data = [['Heavy Industry', 12], ['Retail', 9], ['Light Industry', 14], ['Out of home', 16], ['Commuting', 7], ['Orientation', 9]];
                            var plot1 = jQuery.jqplot(divToBeWorkedOn, [data],
                            {
                                seriesDefaults: {
                                    // Make this a pie chart.
                                    renderer: jQuery.jqplot.PieRenderer,
                                    rendererOptions: {
                                        // Put data labels on the pie slices.
                                        // By default, labels show the percentage of the slice.
                                        showDataLabels: true
                                    }
                                },
                                legend: {
                                    show: true, location: 'e'
                                },
                                cursor: {

                                    show: false,
                                    style: 'pointer'
                                }
                            });

                            $('#chart1').bind('jqplotDataClick',
                                function (ev, seriesIndex, pointIndex, data) {
                                    // $('#info1').html('series: ' + seriesIndex + ', point: ' + pointIndex + ', data: ' + data);
                                    var div = '#info1';
                                    var substr = data.toString().split(',');
                                    var share = substr[0];
                                    var userName = $('#<%= Label1.ClientID %>').text();
                                    var webMethod = 'WebService.asmx/DisplayTransaction';
                                    var gameID = <%= Session["GameID"].ToString().ToLower() %>;
                                    var parameters = "{'ShareName':'" + share + "','GameID':'" + gameID + "','UserName':'" + userName + "'}";

                                    //var data = [];
                                    var html = "<table style='border: medium solid #000000; width: 100%>";
                                    html = html + "<tr><td align='center' colspan='8' style='font-weight: bold; border: thin solid #000000' valign='middle'>" + share + "</td></tr>";
                                    html = html + "<tr><td align='center' colspan='4' style='font-weight: bold; border-style: solid; border-width: thin' valign='middle'>Bought Record</td><td colspan='4' style='font-weight: bold; border-style: solid; border-width: thin' >Sell Record</td></tr>";
                                    html = html + "<tr><td align='center' valign='middle' style='font-weight: bold; border-style: solid; border-width: thin'>Transaction Date</td><td align='center' valign='middle' style='font-weight: bold; border-style: solid; border-width: thin'>Quantity</td><td align='center' valign='middle' style='font-weight: bold; border-style: solid; border-width: thin'>Amount</td><td align='center' valign='middle' style='font-weight: bold; border-style: solid; border-width: thin'>Total</td><td align='center' valign='middle' style='font-weight: bold; border-style: solid; border-width: thin'>Transaction Date</td><td align='center' valign='middle' style='font-weight: bold; border-style: solid; border-width: thin'>Quantity</td><td align='center' valign='middle' style='font-weight: bold; border-style: solid; border-width: thin'>Amount</td><td align='center' valign='middle' style='font-weight: bold; border-style: solid; border-width: thin'>Total</td></tr>";

                                    $.ajax({
                                        type: "POST",
                                        url: webMethod,
                                        data: parameters,
                                        contentType: "application/json; charset=utf-8",
                                        dataType: "json",
                                        success: function (response) {

                                            var trans = response.d;
                                            if (trans != null) {
                                                var buyDate = "";
                                                var currentDate = "";
                                                for (var i = 0; i < trans.length; ++i) {
                                                    var tran = trans[i];
                                                    currentDate = tran.BuyDate;

                                                    if (currentDate != buyDate) {
                                                        buyDate = currentDate;

                                                     if (i != 0)
                                                            html = html + "<tr height='10'><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";

                                                        if(tran.SellDate != "")
                                                            html = html + "<tr><td style='background-color: #66FF66; border: thin solid #000000' align='center' valign='middle'>" + tran.BuyDate + "</td><td style='background-color: #66FF66; border: thin solid #000000' align='center' valign='middle'>" + tran.BuyQuantity + "</td><td style='background-color: #66FF66; border: thin solid #000000' align='center' valign='middle'>" + tran.BuyValue + "</td><td style='background-color: #66FF66; border: thin solid #000000' align='center' valign='middle'>" + tran.BuyTotal + "</td><td style='background-color: #FF0000; border: thin solid #000000' align='center' valign='middle'>" + tran.SellDate + "</td><td style='background-color: #FF0000; border: thin solid #000000' align='center' valign='middle'>" + tran.SellQuantity + "</td><td style='background-color: #FF0000; border: thin solid #000000' align='center' valign='middle'>" + tran.SellValue + "</td><td style='background-color: #FF0000; border: thin solid #000000' align='center' valign='middle'>" + tran.SellTotal + "</td></tr>";

                                                        else if(tran.SellDate == "")                                                    
                                                            html = html + "<tr><td style='background-color: #66FF66; border: thin solid #000000' align='center' valign='middle'>" + tran.BuyDate + "</td><td style='background-color: #66FF66; border: thin solid #000000' align='center' valign='middle'>" + tran.BuyQuantity + "</td><td style='background-color: #66FF66; border: thin solid #000000' align='center' valign='middle'>" + tran.BuyValue + "</td><td style='background-color: #66FF66; border: thin solid #000000' align='center' valign='middle'>" + tran.BuyTotal + "</td><td></td><td></td><td></td><td></td></tr>";
                                                        

                                                    }

                                                    else {
                                                            html = html + "<tr><td></td><td></td><td></td><td></td><td style='background-color: #FF0000; border: thin solid #000000' align='center' valign='middle'>" + tran.SellDate + "</td><td style='background-color: #FF0000; border: thin solid #000000' align='center' valign='middle'>" + tran.SellQuantity + "</td><td style='background-color: #FF0000; border: thin solid #000000' align='center' valign='middle'>" + tran.SellValue + "</td><td style='background-color: #FF0000; border: thin solid #000000' align='center' valign='middle'>" + tran.SellTotal + "</td></tr>";
                                                        //html = html + "<tr><td style='background-color: #66FF66; border: thin solid #000000' align='center' valign='middle'></td><td style='background-color: #66FF66; border: thin solid #000000' align='center' valign='middle'></td><td style='background-color: #66FF66; border: thin solid #000000' align='center' valign='middle'></td><td style='background-color: #66FF66; border: thin solid #000000' align='center' valign='middle'></td><td style='background-color: #FF0000; border: thin solid #000000' align='center' valign='middle'>" + tran.SellDate + "</td><td style='background-color: #FF0000; border: thin solid #000000' align='center' valign='middle'>" + tran.SellQuantity + "</td><td style='background-color: #FF0000; border: thin solid #000000' align='center' valign='middle'>" + tran.SellValue + "</td><td style='background-color: #FF0000; border: thin solid #000000' align='center' valign='middle'>" + tran.SellTotal + "</td></tr>";
                                                    }
                                                }
                                            }

                                            html = html + "</table>";

                                            $(div).html(html);
                                        },
                                        error: function (err) {
                                            $(div).html("Unavailable");
                                        }
                                    });

                                } //Close function (ev, seriesIndex, pointIndex, data)
                            );
                        }
                    }
                },
                error: function (err) {
                    $(divToBeWorkedOn).html("Unavailable");
                }
            });
        })
    </script>

    <style type="text/css">
        .style27
        {
            background-color: #506272;
        }
        .style28
        {
            text-align: center;
            width: 269px;
            font-weight: bold;
            background-color: #CCCCCC;
        }
        .style29
        {
            width: 269px;
        }
        .style30
        {
            width: 248px;
        }
        .style32
        {
            text-align: right;
            width: 177px;
        }
        .style33
        {
            width: 236px;
        }
        .style34
        {
            width: 177px;
        }
        .style36
        {
            width: 248px;
            background-color: #FFFFFF;
        }
        .style37
        {
            text-align: right;
            width: 177px;
            height: 27px;
        }
        .style38
        {
            text-align: center;
            width: 269px;
            font-weight: bold;
            height: 27px;
            background-color: #CCCCCC;
        }
        .style40
        {
            width: 248px;
            height: 27px;
            background-color: #FFFFFF;
        }
        .style41
        {
            text-align: right;
            width: 177px;
            height: 26px;
        }
        .style42
        {
            text-align: center;
            width: 269px;
            font-weight: bold;
            height: 26px;
            background-color: #CCCCCC;
        }
        .style43
        {
            width: 248px;
            height: 26px;
            background-color: #FFFFFF;
        }
        .style44
        {
            height: 26px;
        }
        .style45
        {
            height: 26px;
            background-color: #FFFFFF;
        }
        .style46
        {
            background-color: #FFFFFF;
        }
        .style47
        {
            width: 566px;
        }
    </style>
   
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
     <br />
    <table style="width: 100%; height: 326px;" id="table1">
        <tr>
            <td class="style27" bgcolor="#FF9900" colspan="4">
                <asp:Label ID="Label77" runat="server" 
                    style="font-size: medium; font-weight: 700; color: #FFFFFF;" 
                    Text="User Profile"></asp:Label>
            </td>
        </tr>
        <tr>
            <td class="style32">
                &nbsp;</td>
            <td class="style28">
                User Name</td>
            <td class="style36" style="border: thin solid #000000">
                &nbsp;<asp:Label ID="Label1" runat="server"></asp:Label>
            </td>
            <td class="style33">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style32">
                &nbsp;</td>
            <td class="style28">
                First
                Name :</td>
            <td class="style36" style="border: thin solid #000000">
                <asp:Label ID="Label2" runat="server"></asp:Label>
            </td>
            <td class="style33">
                </td>
        </tr>
        <tr>
            <td class="style32">
                &nbsp;</td>
            <td class="style28">
                Last
                Name :</td>
            <td class="style36" style="border: thin solid #000000">
                <asp:Label ID="Label3" runat="server"></asp:Label>
            </td>
            <td class="style52">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style32">
                &nbsp;</td>
            <td class="style28">
                Nationality :</td>
            <td class="style36" style="border: thin solid #000000">
                <asp:Label ID="Label4" runat="server"></asp:Label>
            </td>
            <td class="style46">
                </td>
        </tr>
        <tr>
            <td class="style41">
                </td>
            <td class="style42">
                Email Address :</td>
            <td class="style43" style="border: thin solid #000000">
                <asp:Label ID="Label6" runat="server"></asp:Label>
            </td>
            <td class="style45">
                </td>
        </tr>
        <tr>
            <td class="style37">
                </td>
            <td class="style38">
                Contact Number :</td>
            <td class="style40" style="border: thin solid #000000">
                <asp:Label ID="Label7" runat="server"></asp:Label>
            </td>
            <td class="style40">
                </td>
        </tr>
        <tr>
            <td class="style41">
                </td>
            <td class="style42">
                Occupation :</td>
            <td class="style43" style="border: thin solid #000000">
                <asp:Label ID="Label8" runat="server"></asp:Label>
            </td>
            <td class="style44">
                </td>
        </tr>
        <tr>
            <td class="style32">
                &nbsp;</td>
            <td class="style28">
                Company :</td>
            <td class="style36" style="border: thin solid #000000">
                <asp:Label ID="Label9" runat="server"></asp:Label>
            </td>
            <td class="style58">
                </td>
        </tr>
        <tr>
            <td class="style32">
                &nbsp;</td>
            <td class="style28">
                Referral Code :</td>
            <td class="style36" style="border: thin solid #000000">
                <asp:Label ID="Label111" runat="server"></asp:Label>
            </td>
            <td class="style58" align="left">
                <asp:Button ID="Button3" runat="server" Height="28px" 
                    PostBackUrl="~/Referal.aspx" Text="Refer a friend" Width="120px" 
                    style="text-align: left" onclick="Button3_Click" />
            </td>
        </tr>
        <tr>
            <td class="style32">
                &nbsp;</td>
            <td class="style28">
                Account Amount:</td>
            <td class="style36" style="border: thin solid #000000">
                $<asp:Label ID="Label10" runat="server"></asp:Label>
            </td>
            <td class="style58">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style34">
                &nbsp;</td>
            <td class="style29">
                &nbsp;</td>
            <td style="text-align: right;" class="style30">
                <asp:Button ID="Button1" runat="server" Height="28px" 
                    PostBackUrl="~/UserManagement.aspx" Text="Edit" Width="75px" 
                    onclick="Button1_Click" />
            </td>
            <td class="style58">
                <asp:HyperLink ID="AdminHyperLink1" runat="server" 
                    NavigateUrl="~/GlobalSetting.aspx" Visible="False">Access to Administrator page</asp:HyperLink>
            </td>
        </tr>
        <tr>
            <td class="style62" colspan="4" valign="top">
                <br />
                
              </table>
                <table style="width: 100%; height: 481px; margin-top: 0px;" 
         id="table2">
                    <tr>
                        <td class="style27" bgcolor="#CCCC00" colspan="2">
                            <asp:Label ID="Label88" runat="server" 
                                style="font-weight: 700; font-size: medium; color: #FFFFFF;" 
                                Text="My Current Stock Market Value"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="style47">
                            <div id="chart1" style="height:350px;width:460px; ">
                            </div>
                            </td>
                        <td class="style73" valign=top>
                            <div id="info1"></div>
                            </td>
                    </tr>
                    <tr>
                        <td class="style77" valign="top" align=left colspan="2">

    <asp:Label ID="zoom_label" runat="server" ForeColor="#FF3300" 
        Text="** You can click on the piechart for more details  **"></asp:Label>

                        </td>
                    </tr>
                    <tr>
                        <td class="style7" valign="top" align=center colspan="2">
                            <asp:Button ID="Button2" runat="server" PostBackUrl="~/Stock History.aspx" 
                                Text="Stock History" />
                            </td>
                    </tr>
                    <tr>
                        <td class="style78" valign="top" align="center" colspan="2">
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style79" valign="top" align="center" colspan="2">
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style80" valign="top" colspan="2">
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style76" valign="top" colspan="2">
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="style72" colspan="2">
                            &nbsp;</td>
                    </tr>
                </table>
          
            </asp:Content>

